#pragma once

#include "Const.h"
#include "GameData.h"
#include "AI.h"
#include "AIThread.h"
#include "GameRecord.h"

#include <QObject>

class GameEngine: public QObject
{
    Q_OBJECT
public:
	GameEngine(void);
	virtual ~GameEngine(void);

	void ProcessNew();
	GB::CHESS_TYPE ProcessOrder(int row, int line);
	GB::GAME_RESULT GetResult(int row, int line);
	int GetEval(GB::CHESS_TYPE type);    
    void SetLevel(int level);
    void AIThrFunc();
    void ModifyMode();
    void SaveRecord(QString fileName);
    void LoadRecord(QString fileName);
    void Replay();

signals:
    void Order(int row, int line, GB::CHESS_TYPE type);

private:    
	enum GAME_STATE
	{
		INIT_STATE,
		BLACK_STATE,
		WHITE_STATE,
        AI_STATE,
		FINAL_STATE,
        RECORD_STATE
	};
	GAME_STATE state;
	GameData data;
    AI *ai;
    AIThread aiThr;
    GameRecord record;
    GB::CHESS_TYPE recordType;
};

